//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using EntLibContrib.Query.Configuration;

namespace EntLibContrib.Query.Parameters
{
	/// <summary>
	/// Type to hold the elements of a single database query parameter
	/// </summary>
	[ConfigurationElementType(typeof(DataParameterData))]
	public class DataParameter : Parameter
	{
		#region Fields
		private DbType type;
		private ParameterDirection direction;
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the type of the parameter.
		/// </summary>
		/// <value>The type of the parameter.</value>
		public DbType DbType
		{
			get { return type; }
			set { type = value; }
		}

		/// <summary>
		/// Gets or sets the parameter direction.
		/// </summary>
		/// <value>The parameter direction.</value>
		/// <remarks>the directions are In or Out</remarks>
		public ParameterDirection Direction
		{
			get { return direction; }
			set { direction = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new default instance of the <see cref="DataParameter"/> class.
		/// </summary>
		/// <param name="name">The parameter name.</param>
		public DataParameter(string name)
			: this(name, DbType.Guid, ParameterDirection.Input)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="DataParameter"/> class.
		/// </summary>
		/// <param name="name">The parameter name.</param>
		/// <param name="type">The type.</param>
		public DataParameter(string name, DbType type)
			: this(name, type, ParameterDirection.Input)
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="DataParameter"/> class.
		/// </summary>
		/// <param name="name">The parameter name.</param>
		/// <param name="type">The parameter type.</param>
		/// <param name="direction">The direction of the parameter relative to the DataSet.</param>
		public DataParameter(
			string name,
			DbType type,
			ParameterDirection direction
			)
			: base(name)
		{
			this.type = type;
			this.direction = direction;
		}
		#endregion
	}
}
